package org.jspar.partition;

import org.jspar.Options;

/**
 * VARIANT 4:  A partition is acceptable if the parent represents 
 * an increace in the ratio of the c/s among the branches...
 * (So a good partition will represent a local c/s minima)
 */
public class SlopeRatioRule extends PartitionRule {

	public SlopeRatioRule(Options options) {
		super(options);
	}

	public boolean isAcceptable(Cluster ci, Cluster cj, int c) {
		double ovRatio = (double) c / (ci.size() + cj.size());
		double lRatio = (double) ci.connections() / ci.size();
		double rRatio = (double) cj.connections() / cj.size();

		double maxChildRatio = lRatio > rRatio ? lRatio : rRatio;

		return ovRatio >= maxChildRatio;
	}
}
